<!--
Copyright 2003 Cordys R&D B.V. 

This file is part of the Cordys SAP Connector. 

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!--
 Project  : Cordys SAP Connector
 File Name : SAPJCOMethodPublisher.htm
 Description : This page is used to read SAP Message Types.
 author : Vijaya Gopal ??
 ======================== adjustment for BOP4 compliance ===============================================
 **                                                                                                   **
 ** changed: 26.aug2009: Helmut Boecker - moved the  tag </head> from end of dataisland before script **
 ** changed: 26.aug2009: Helmut Boecker - <html xmlns:eibus="xmlns:eibus"                             **
 ** changed: 26.aug2009: Helmut Boecker - window.application.container.close()                        **
 ** changed: 26.aug2009: Helmut Boecker - added application.js                                        **
 ** changed: 26.aug2009: Helmut Boecker - added "div" for style eibus\:select                         **
 ** changed: 26.aug2009: Helmut Boecker - removed link to behaviors.css                               **
 ** changed: 26.aug2009: Helmut Boecker - changed "window.event.data" to "application.event.data"     **
 **                                                                                                   **
 **                                                                                                   **
-->
<html xmlns:eibus="xmlns:eibus" onselect="parent_id()">
    <head>
        
	<script src="/cordys/wcp/application.js" >
	</script>
      <style>
			<style>
			label {	 font-size:11; font-family:verdana; font-weight:normal; }
			input {	 font-size:11; font-family:verdana; font-weight:normal;}
      eibus\:select div{font-size:11; font-family:verdana;}
			button { font-size:11; font-family:verdana; width:95px}	
		</style>
		</style>
        
 </head>
        <script language="JScript">
			//	Unicode character indicating enter and esc keys.
			var ENTER_KEY="13";
			var ESC_KEY="27";
			var mestype;
			var parent_id;
			
			function parent_id()
			{
				parent_id=application.event.data;
			}					
			
			//	On press of 'Enter' and 'Esc' it does a 'Find' and closes the
			//	window respectively.
			function keyPressed()
			{
				var keyPressed = window.event.keyCode;
				
				if (keyPressed == ESC_KEY)
				{
					window.application.container.close(); // 26.aug2009 - hb: add "window."
				}
				else if (keyPressed == ENTER_KEY)
				{
					getMessage(val);
				}
			}
			
			
			//This function is used to get the parameters supplied from User and paas these parameters in the function to get desire results
			function getData()
			{
        // ** ==> commented by hb: 26.aug2009
				//requestMessage.selectSingleNode(".//fromMSGTYPE").text = FromMessageType.value;
				//requestMessage.selectSingleNode(".//toMSGTYPE").text = ToMessageType.value;
				//bdiMessage.request= requestMessage.XMLDocument;
        // ** <== commented by hb: 26.aug2009

        // ** ==> NEW by hb: 26.aug2009
			  var clone_requestMsg = requestMessage.XMLDocument.cloneNode(true);
				clone_requestMsg.selectSingleNode(".//fromMSGTYPE").text = FromMessageType.value;
				clone_requestMsg.selectSingleNode(".//toMSGTYPE").text = ToMessageType.value;
	      bdiMessage.request = clone_requestMsg ;
	      bdiMessage.clear();
	      bdiMessage.parameters.receiver = null;
        // ** <== NEW by hb: 26.aug2009

				bdiMessage.reset();
				fillgrid();
			}

			
			//This function is used to clear to the text boxes
			function clear_text()
			{
				ToMessageType.value="";
				FromMessageType.value="";
			}

			//This function is used to fill data in grid
			function fillgrid()
			{
				var  items = bdiMessage.data.selectNodes(".//item");
				var row = tBody.firstChild.cloneNode(true);
				tBody.removeChild(tBody.firstChild);
				for (var count = 0; count < items.length;count++)
				{
					row.firstChild.firstChild.value = items[count].getAttribute("MESTYP");
					tBody.appendChild(row.cloneNode(true));
					
				}					
				gridMessageType.redraw();			
			}


			//This function is used to extract Message Type 
			function getMestyp(html,object,node)
			{
				html.value = node.getAttribute("MESTYP");				
			}
			
			//This function is used to paas the Message Types from child page to parent child on double click of the selected data
			function getMessage(val)
			{
				system.windows[parent_id].MessageType.value=mestype;				
				window.application.container.close();		
				system.windows[parent_id].IdocType();				
			}
			
			//This function is used to paas the Message Types from child page to parent child on single click of the selected data
			function singleclick(val1)
			{
				mestype=val1;
				ok_button.disabled=false;
			}
			
			function getMessageType()
			{
				system.windows[parent_id].MessageType.value=mestype;				
				window.application.container.close();		
				system.windows[parent_id].IdocType();			
			}
			

		</script>

<!---------------Bus data island for getting Message Types from SAP---------------->
		
    <eibus:dataisland id="bdiMessage" async="false" automatic="false">
			<xml id="requestMessage">
				<SOAP:Envelope xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/">
					<SOAP:Body>
						<GetIDOCMessageTypes xmlns="http://schemas.cordys.com/1.0/SAPSchema">
							<fromMSGTYPE>a</fromMSGTYPE>
							<toMSGTYPE>z</toMSGTYPE>
							<overwrite>false</overwrite>
						</GetIDOCMessageTypes>
					</SOAP:Body>
				</SOAP:Envelope>
			</xml>
		</eibus:dataisland>
<!--------------------------------------------------------------------------------->   

    <body onkeypress="keyPressed()" class="light">
	
		<font size="2">
		&nbsp;&nbsp;&nbsp;
		<label>Search criteria</label>
		</font>
	
			<div class="input light" style="font-size: 100%; width: 90%; left:30px; cursor: default;top:30px; position: absolute; height: 30%; background-repeat: repeat; background-attachment: scroll; border-style: solid; border-width: 1px">
				<table width="90%"  style="left:10px">
					<tr>
						<td align="right" width="100%">fromMSGTYPE</td>
						<td width="100%">
							<input style="text-align: left;" class="validate input" id="FromMessageType" validationLevel="form" required="true" fieldType="text">
						</td>
					</tr>

					<tr>
						<td align="right" width="100%" >toMSGTYPE</td>
						<td>
	                        <input width="100%" style="text-align: left;" class="validate input" id="ToMessageType"  validationLevel="form" required="true" fieldType="text">
						</td>
					</tr>

					<tr></tr>

					<tr>
						<td align="right"  width="100%" >&nbsp;&nbsp;&nbsp;
							<input class="medium" onclick="getData()" style="WIDTH: 50px" type="button"	 value="Search">
						</td>

						<td align="left"  width="100%">&nbsp;
							<input class="medium" onclick="clear_text()" style="WIDTH: 50px" type="button" value="Clear">
						</td>
					</tr>
				</table>
			</div>		
		
		
			<div style="font-size: 100%; width: 90%; cursor: default;left:30px; position: absolute; background-repeat: repeat; background-attachment: scroll; top: 184; height: 30%;">	       
			<table class="grid" id="gridMessageType" selectType="multiple" saveState="false" width="100%" class="lightmedium">
				<thead align="middle">
					<tr class="light">
						<td style="border: 1px solid gray"  width="100%">
							<label style="TEXT-ALIGN: center">Message Type</label>
						</td>
					</tr>
				</thead>

				<tbody id="tBody">
					<tr>
						<td style="border: 1px solid gray" width="100%">
							<input class="input" id="grid_message" readonly="true" style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-LEFT: 0px; BORDER-BOTTOM: 0px; TEXT-ALIGN: left;background:transparent" ondblclick="getMessage(this.value)" onclick="singleclick(this.value)" size="44">
						</td>
					</tr>
				</tbody>
			</table>
		
			<table width="100%">
				<tr>
					<td align="middle"  width="100%">
                        <input class="medium" style="width:50px" onclick="getMessageType()" name="ok_button" type="button" value="OK" disabled align="right">
						<input class="medium" style="width:50px" onclick="window.application.container.close()" type="button" value="Cancel">
					</td>
				</tr>
			</table>
	      </div>
	    
	</body>
</html>